package demo1;

import java.util.Arrays;

public class Test2 {
    public static void main(String[] args) {
        Student student1 = new Student("zhangsan", 10);
        Student student2 = new Student("lisi", 19);
        //System.out.println(student1.compareTo(student2));

        Student[] students = new Student[]{new Student("zhangsan", 10),
                new Student("lisi", 19),
                new Student("wangwu", 8)};
        //students[0] = new Student("zhangsan", 10);
        //System.out.println(students[0]);

        System.out.println("排序前："+ Arrays.toString(students));

        NameComparator nameComparator = new NameComparator();
        AgeComparator ageComparator = new AgeComparator();
        Arrays.sort(students, ageComparator);
        //mySort(students);
        System.out.println("按照年龄排序后："+Arrays.toString(students));
        Arrays.sort(students, nameComparator);
        System.out.println("按照姓名排序后：" + Arrays.toString(students));

        //equals是比较两个对象一样不一样，返回值是true或者false
        //比较两个大小
        int ret = ageComparator.compare(student1,student2);
        System.out.println(ret);
    }
}
